Table of Contents [Hide/Show]
Jetfire Code: News Item See Also
// N E W S ========================================================================== // News.txt //=================================================================================== // Copyright (C) 2009 TrackerRealm Corporation // This file is part of Jetfire. http://Jetfire.ca // // Jetfire is open software: you can redistribute it and/or modify it under the terms of the // GNU General Public License as published by the Free Software Foundation, version 3 of the License. // // Jetfire is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. // See the GNU General Public License for more details. // // You should have received a copy of the GNU General Public License along with Jetfire. // If not, see http://www.gnu.org/licenses. // REMOVAL OF THIS NOTICE IS VIOLATION OF THE COPYRIGHT. //=================================================================================== // DisplayName = "News Item"; // ToolTip = "News Item displays news items for a specific time interval. Use Workspace to deliver news to specific teams."; //=================================================================================== // namespace JetfireApps { // This workflow creates News Items with an expiry date. // Use 'IsCurrent' to check the Expiry Date and identify if the News Item is current. // state ActiveTopic means that the News Item is current. public workflow NewsItem { // Add workflow constructor public NewsItem() { Tags = new List(); enterstate Start(); Created_Date = DateTime.Now; Created_By = Nexus.LoginUser.Name; Expiry_Date = DateTime.Today.AddYears(1); } // Add states to the workflow public Start() { } public ActiveTopic() { } public InactiveTopic() { } // Add Properties // Use Subject as News Title // Use ToolTip as News Description // Add Expiry Date public bool Never_Expires { get; set; } public DateTime Created_Date { get; private set; } public plainString Created_By { get; private set; } public DateTime Expiry_Date { get; set; } public List Tags { get; private set; } public bool IsCurrent { get { if (Never_Expires) return true; if (DateTime.Now.Preceeds(Expiry_Date)) return true; // This news item is now expired enterstate InactiveTopic(); return false; } } // Add Command Methods public void FinishEdit() : states(Start,ActiveTopic) { if (Subject == "") throw exception("Enter Title"); if (ToolTip == "") throw exception("Enter Description"); enterstate ActiveTopic(); } public void Set_Inactive() : states(ActiveTopic) { enterstate InactiveTopic(); } public void Set_Active() : states(InactiveTopic) { enterstate ActiveTopic(); } } }